package com.example;

import com.example.Config.RabbitMQConfig;
import com.example.Receiver.MessageReceiver;
import com.example.Sender.MessageSender;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.PostConstruct;


//不可以省略@SpringBootTest,否则监听不到MQ配置
@SpringBootTest
public class MQTestDemo {
    @Autowired
    private MessageSender messageSender;
//    @Test
//    public void testDemo1(){
//            messageSender.sendMessage("我想跟你说：希望你开心快乐！！！");
//    }
//
//    @Test
//    public void testDemo2(){
//        messageSender.sendMessage("相信梦想。。。。。。");
//    }
//
//    @Test
//    public void testDemo3(){
//        messageSender.sendMessage("相信梦想。。。。。。");
//    }

//    @Autowired
//    private MessageSender producer;
////    @PostConstruct
//    @Test
//    public void test() {
//        producer.send("hello, queue 1", RabbitMQConfig.ROUTING_KEY_1);
//        producer.send("hello, queue 2", RabbitMQConfig.ROUTING_KEY_2);
//    }
/**
 * 主题模式
 */
    @Autowired
    private MessageSender producer;
    @Test
    public void test() {
        producer.send("hello, queue 1", RabbitMQConfig.ROUTING_KEY_1);
        producer.send("hello, queue 2", RabbitMQConfig.ROUTING_KEY_2);
        producer.send("hello, queue 3", RabbitMQConfig.ROUTING_KEY_3);
    }

}

